import bisect
class Solution(object):
    def maxDistance(self, nums1, nums2):
        nums1 = [- num for num in nums1]
        nums2 = [-num for num in nums2]
        max_len = 0
        for index, num in enumerate(nums1):
            r_index = bisect.bisect_right(nums2, num, index)
            max_len = max(r_index - index - 1, max_len)
        return max_len